package top.hiai.util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;
/**
* @Author www.hiai.top
* @Email  goodsking@163.com
* @Message 更多资源尽在www.hiai.top,开发者：黄康权
* @Introduction MD5加密工具，现在已经更新了，建议用户可以百度更新的使用方法
*/


public class Md5Util {
	//对密码MD5加密
	public static String EncoderPwdByMd5(String str)throws NoSuchAlgorithmException,UnsupportedEncodingException{
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		BASE64Encoder base64en = new BASE64Encoder();
		return base64en.encode(md5.digest(str.getBytes("utf-8")));
		//return base64en.decodeBuffer(md5.digest(str.getBytes("utf-8")));
	}
	//测试加密
	public static void main(String[] args)throws NoSuchAlgorithmException,UnsupportedEncodingException {
		System.out.println(EncoderPwdByMd5("huang199815"));
	}
}
